<?php
	session_start();
	$auth = isset($_SESSION['s_auth']['identifikasi_titik']) ? $_SESSION['s_auth']['identifikasi_titik'] : NULL;	
	
	if( $auth == NULL || $auth == 'view' ){
		die('&copy; 2009 Mekarsari Web-GIS');
	}	
	
	$pancang_id	= isset($_POST['id'])? $_POST['id'] : 1;	
	
	include 'ajax_config.php';
	
	// MODE : EDIT	
	$x = $db->get_results("SELECT * FROM individu WHERE no_pancang='$pancang_id'", ARRAY_A);
	$x = $x[0];	
	if( count($x) < 1 ){
	?>
	<table cellspacing="0" cellpadding="3">
		<tr>
			<td>Data tidak ditemukan</td>
		</tr>			
	</table>
	<?php
	}
	else{
	?>
	<style>
	#editForm input{
			font-family: Georgia, "Times New Roman", Times, serif;
			font-size: 11px;
	}
	</style>
	<script language="javascript">
	var update = {	
			param: '',
			send: function(form){
				this.param = '';
				for(var i=0; i<form.elements.length; i++){
					el = form.elements[i];
					
					if(el.type == 'text'){
						this.param += el.name+'='+el.value+'&';
					}
				}
				this.param = this.param + 'mode=edit';  // mode = edit..
				
				myUpdate.send(this.param);
				return false;
			}
	}
	
		// cek angka		
	function cekAngka(el){
		var invalidNumber = /[^0-9.,]/;
		if ( invalidNumber.test(el.value) ){
			alert('Harus angka');
			el.value = '';
			el.focus();
		}
	}
	</script>
	<form method="post" action="process.php" name="editForm" id="editForm" onsubmit="return update.send(this);return false;">
	<div id="log"></div>
	<table width="296" cellpadding="3" cellspacing="0">
	  <tr>
		<td><div align="left">No Pancang </div></td>
		<td>:</td>
		<td>
		  <input name="no_pancang" type="text" id="no_pancang" value="<?=$x['no_pancang'];?>" disabled="disabled"/>	    
		<div align="left"></div></td>
	  </tr>
	  <tr>
		<td width="129"><div align="left">No Individu </div></td>
		<td width="3">:</td>
		<td width="144"><input type="text" name="no_individu" id="no_individu" value="<?=$x['no_individu'];?>"/>
		<div align="left"></div></td>
	  </tr>

	  <tr>
		<td><div align="left">Tanggal Tanam </div></td>
		<td>:</td>
		<td valign="middle" nowrap="nowrap">
		  <div align="left">
			<input name="tgl_tanam" type="text" id="tgl_tanam" value="<?=$x['tgl_tanam'];?>" size="15" readonly="readonly"/>          
			<img src="images/calendar.png" onclick="displayDatePicker('tgl_tanam');" >
		</div></td>
	  </tr>
	  <tr>
		<td><div align="left">Replika </div></td>
		<td>:</td>
		<td>
		  <input name="replika" type="text" id="replika" value="<?=$x['replika'];?>" />	    
		<div align="left"></div></td>
	  </tr>
	  <tr>
		<td><div align="left">Usia Saat Tanam </div></td>
		<td>:</td>
		<td>
		  <input name="usia_saat_tanam" type="text" id="usia_saat_tanam" value="<?=$x['usia_saat_tanam'];?>" onchange="cekAngka(this)" />	    
		<div align="left"></div></td>
	  </tr>
	  <tr>
		<td><div align="left">Crossing Asal Pokok </div></td>
		<td>:</td>
		<td>
		  <input name="cross_asal_pokok" type="text" id="cross_asal_pokok" value="<?=$x['cross_asal_pokok'];?>" />	    
		<div align="left"></div></td>
	  </tr>
	  <tr>
		<td><div align="left">Jenis Tanaman </div></td>
		<td>:</td>
		<td>
		  <input name="jenis_tanaman" type="text" id="jenis_tanaman" value="<?=$x['jenis_tanaman'];?>" />	    
		<div align="left"></div></td>
	  </tr>
	  <tr>
		<td><div align="left">Ketegori Pokok Saat Tanam </div></td>
		<td>:</td>
		<td>
		  <input name="kategori_pokok_saat_tanam" type="text" id="kategori_pokok_saat_tanam" value="<?=$x['kategori_pokok_saat_tanam'];?>" />	    
		<div align="left"></div></td>
	  </tr>
	  <tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td><div align="left"></div></td>
	  </tr>
	  <tr>
		<td colspan="3"><div align="center">&nbsp;
			<input type="submit" name="submit" value="Update"/>&nbsp;
			<input type="reset" name="reset" value="Reset" />&nbsp;
			<input type="button" name="back" value="Batal" onclick="myRequest.send('id=<?=$pancang_id;?>');" />
		</div></td>
	  </tr>			  
	  </table>
	</form>
	<?php
	}
	?>